package IO;

/**
 *
 * @author Sara Tily
 */

import Common.Utils;
import java.io.File;
import java.io.FileFilter;


public class TrainingFileFilter 
	extends javax.swing.filechooser.FileFilter implements FileFilter 
{
	boolean includeDirectories = true;

	public TrainingFileFilter() {}
	public TrainingFileFilter(boolean includeDirectories) {
		this.includeDirectories = includeDirectories;
	}

    //Accept all directories and all gif, jpg, tiff, or png files.
    public boolean accept(File f) {
        if (f.isDirectory() && includeDirectories) {
            return true;
        }

        String suffix = Utils.getFileSuffix(f);
        if (suffix != null) {
            if (suffix.equals(Utils.tiff) ||
                suffix.equals(Utils.tif) ||
                suffix.equals(Utils.gif) ||
                suffix.equals(Utils.jpeg) ||
                suffix.equals(Utils.jpg) ||
                suffix.equals(Utils.png))
			{
				return true;
            } else {
				return false;
            }
        }

        return false;
    }

    //The description of this filter
    public String getDescription() {
        return "*.tiff; *.tif; *.gif; *.jpeg; *.jpg; *.png";
    }
}
